package com.example.music.room;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;

import java.util.List;

@Dao
public interface UserDao {
    @Query("SELECT * FROM user")
    List<User> getAll();

    @Query("SELECT * FROM user WHERE uid IN (:userIds)")
    List<User> loadAllByIds(int[] userIds);

    @Query("SELECT * FROM user WHERE name LIKE :name AND " + "pass_word LIKE :passWord LIMIT 1")
    User findByName(String name, String passWord);

    @Query("SELECT * FROM user WHERE is_online LIKE :online LIMIT 1")
    User findByOnline(Boolean online);

    @Update
    void updateUser(User user);

    @Insert(onConflict = OnConflictStrategy.IGNORE)
    void insert(User users);

    @Insert(onConflict = OnConflictStrategy.IGNORE)
    void insert(User... users);

    @Delete
    void delete(User user);

    @Query("DELETE  FROM user where name=:name")
    void delete(String name);
}
